#coding=utf-8
'''
Created on 2013-9-3

@author: Ben

单个武将数据
'''

#空闲
GENERAL_STATE_FREE = 0
#募兵
GENERAL_STATE_RECRUIT = 1
#国战
GENERAL_STATE_WAR = 3
#国战单挑
GENERAL_STATE_SOLO = 13

#空闲
C_STATE_FREE = 0
#移动
C_STATE_MOVE = 6
#牢房
C_STATE_PRISON = 22
#逃跑
C_STATE_ESCAPE = 23

class GeneralVO:
    '''
    classdocs
    '''
    #武将id
    generalId = 0
    #武将状态
    generalState = 0
    #辅助状态
    cState = 0
    #武将等级
    generalLv = 0
    #当前兵力
    forces = 0
    #最大兵力
    forcesMax = 0
    #武将头像
    pic = ""
    #武将所在城市
    generalLocationId = 0

    def __init__(self, data):
        '''
        Constructor
        '''
        self.update(data)
    
    '''
            更新武将数据
    '''
    def update(self, data):
        if "generalId" in data:
            self.generalId = int(data["generalId"])
        if "generalState" in data:
            self.generalState = int(data["generalState"])
        #挺奇怪的一段逻辑
        if "cState" in data:
            self.cState = int(data["cState"])
        elif self.cState != C_STATE_PRISON and self.cState != C_STATE_ESCAPE:
            self.cState = 0
        if "generalLv" in data:
            self.generalLv = int(data["generalLv"])
        if "forces" in data:
            self.forces = int(data["forces"])
        if "forcesMax" in data:
            self.forcesMax = int(data["forcesMax"])
        if "pic" in data:
            self.pic = data["pic"]
        if "generalLocationId" in data:
            self.generalLocationId = data["generalLocationId"]
            
    '''
            获取武将状态描述
    '''
    def getGeneralStateStr(self):
        stateStr = ''
        if self.cState == C_STATE_PRISON:
            stateStr = '武将被困牢房'
        elif self.cState == C_STATE_ESCAPE:
            stateStr = '武将牢房逃跑中'
        elif self.cState == C_STATE_MOVE:
            stateStr = '武将移动中'
        elif self.generalState == GENERAL_STATE_FREE:
            stateStr = '武将空闲'
        elif self.generalState == GENERAL_STATE_RECRUIT:
            stateStr = '武将募兵中'
        elif self.generalState == GENERAL_STATE_WAR:
            stateStr = '武将国战中'
        elif self.generalState == GENERAL_STATE_SOLO:
            stateStr = '武将国战单挑中'
        else:
            stateStr = '未知武将状态' + str(self.generalState)
        return stateStr